<?php 
	include_once $_SERVER["DOCUMENT_ROOT"].'/service/entite/uc/UcEntite.php';
	include_once $_SERVER["DOCUMENT_ROOT"].'/persistence/uc/UcDAO.php';
	include_once $_SERVER["DOCUMENT_ROOT"].'/service/entite/VO.php';
	include_once $_SERVER["DOCUMENT_ROOT"].'/service/entite/uc/UcService.php';
	include_once $_SERVER["DOCUMENT_ROOT"].'/service/uc/gereruc/GererUcUcVO.php';
	include_once $_SERVER["DOCUMENT_ROOT"].'/service/uc/gereruc/GererUcRoleVO.php';
	
	
	class GererUcVOAssembler{
		public static function createGererUcRoleVO(RoleEntite $role) {
			$gererUcRoleVO = new GererUcRoleVO();
			$gererUcRoleVO->id = $role->id;
			$gererUcRoleVO->code = $role->code;
			$gererUcRoleVO->libelle = $role->libelle;
			return $gererUcRoleVO;
		}
		
		public static function createGererUcRoleVOMinimaliste($idRole) {
			$gererUcRoleVO = new GererUcRoleVO();
			$gererUcRoleVO->id = $idRole;
			return $gererUcRoleVO;
		}
		
		
		
		public static function createGererUcUcVO(UcEntite $uc) {
			$gererUcUcVO = new GererUcUcVO();
			$gererUcUcVO->id = $uc->id;
			$gererUcUcVO->code = $uc->code;
			$gererUcUcVO->libelle = $uc->libelle;
			$gererUcUcVO->listeRoleVO = Array();
			$listeRole = UcService::getListeRoleAssocieAUc($uc->id);
			foreach ($listeRole as $role) {
				$gererUcRoleVO = GererUcVOAssembler::createGererUcRoleVO($role);
				$gererUcUcVO->listeRoleVO[] = $gererUcRoleVO;
			}
			return $gererUcUcVO;
		}
		
		public static function getEntity(GererUcUcVO $gererUcUcVO) {
			if ($gererUcUcVO->id == VO::getUnpersistedId()) {
				$uc = new UcEntite();
			} else {
				$uc = UcDAO::getUcByID($gererUcUcVO->id);
			}
			$uc->id = $gererUcUcVO->id;
			$uc->code = $gererUcUcVO->code;
			$uc->libelle = $gererUcUcVO->libelle;
			return $uc;
		}
		
		public static function createListeGererUcUcVO($listeUcEntite) {
			$listeGererUcUcVO = Array();
			foreach ($listeUcEntite as $ucEntite) {
				$listeGererUcUcVO[] = GererUcVOAssembler::createGererUcUcVO($ucEntite);
			}
			return $listeGererUcUcVO;
		}
	}

?>